package ihm;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;
import javax.swing.JFrame;

public class YouWinFrame extends JFrame {

	private Jeu jeu;
	HiddenButton CloseButton;

	public YouWinFrame(Jeu jeu) {

		super("Configuration GAME N WATCH");
		this.jeu = jeu;
		initFrame();

		setVisible(true);
	}

	private void initFrame() {
		Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
		this.setLocation(dim.width / 2 - 400 / 2, dim.height / 2 - 300 / 2);
		this.setLayout(null);
		setResizable(false);
		setSize(400, 300);
		setUndecorated(true);
		try {
			BufferedImage bf = ImageIO.read(new File("res/img/YouWin.jpg"));
			this.setContentPane(new FrameBackGround(bf));
		} catch (Exception e) {
			e.printStackTrace();
		}

		CloseButton = new HiddenButton(null, null, null);
		CloseButton.setBounds(376, 5, 15, 15);
		CloseButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// Execute when button is pressed
				jeu.requestFocus();
				dispose();
			}
		});

		this.add(CloseButton);
		this.setFocusable(true);
	}
}
